package org.inspursc.s0517.health.common.dao;

import org.inspursc.s0517.health.common.entity.SysRole;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface SysRoleDao extends JpaRepository<SysRole, Integer> {
    Page<SysRole> findByNameLike(String username, Pageable pageable);

    @Query(value = "SELECT * from sys_role r LEFT JOIN sys_role_user sru ON  r.id=sru.sys_role_id where sru.sys_user_id=?1", nativeQuery = true)
    List<SysRole> findByUserId(Integer userId);

    SysRole findByName(String name);
}
